package cn.azr.domain.strategy.model.entity;

import cn.azr.types.common.Constants;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * ClassName:StrateEnntity
 * Description:
 *
 * @version 1.0
 * @Author azr
 * @Create 2024/9/29 10:52
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class StrategyEntity {
    /** 抽奖策略ID */
    private Long strategyId;
    /** 抽奖策略描述 */
    private String strategyDesc;
    /** 抽奖规则类型【rule_random - 随机值计算、rule_lock - 抽奖几次后解锁、rule_luck_award - 幸运奖(兜底奖品)】 */
    private String ruleModel;
    public String[] ruleModels() {
        if (StringUtils.isBlank(ruleModel)) return null;
        return ruleModel.split(Constants.SPLIT);
    }

    public String getRuleWeight() {
        String[] ruleModels = this.ruleModels();
        if (ruleModels==null){
            return null;
        }
        for (String ruleModeltemp : ruleModels) {
            if ("rule_weight".equals(ruleModeltemp)) return ruleModeltemp;
        }
        return null;
    }

}
